<template>
  <div>
    <el-table
      v-if="visible"
      :data="blogList"
      stripe
      style="width: 100%">
      <el-table-column
        prop="name"
        label="标题">
      </el-table-column>
      <el-table-column
        prop="date1"
        label="日期">
      </el-table-column>
      <el-table-column
        prop="type"
        label="类型">
      </el-table-column>
      <el-table-column
        label="内容">
        <template slot-scope="scope">
          <!-- <router-link to="bloglist/2"> -->
          <el-button type="primary" @click="handleClick(scope.$index)">查看</el-button>
          <el-button type="danger" @click="deleteBlog(scope.$index)">删除</el-button>
          <!-- </router-link> -->
        </template>
      </el-table-column>
    </el-table>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  computed: {
    blogList () {
      return this.$store.getters.manageBlogs
    },
    visible () {
      return this.$route.name
    }
  },
  methods: {
    detail () {
      this.$route.params.id = 1
      this.$router.to()
    },
    handleClick (row) {
      this.$router.push('bloglist/' + (row + 1))
    },
    deleteBlog (index) {
      this.$store.commit('delete', index)
    }
  }
}
</script>
